import { Component, OnInit, Inject, forwardRef, ViewChild } from '@angular/core';
import { LeadDownloadActivityGridComponent } from './lead-download-activity-grid/lead-download-activity-grid.component';
import { AppComponent } from '../../../app.component';
import { path } from '../../../path.config';

import { masterService } from '../../../../lib/master.service';

@Component({
    selector: 'h5-lead-download-activity-management',
    templateUrl: './lead-download-activity-management.component.html',
    styleUrls: ['./lead-download-activity-management.component.css']
})
export class LeadDownloadActivityManagementComponent implements OnInit {
    @ViewChild('LeadDownloadActivityGoodsGrid') LeadDownloadActivityGoodsGrid: LeadDownloadActivityGridComponent;
    
    public filter = {
        pageSize: '10',
        pageIndex: '1',
        activityName: '',
        enabled: ''
    }

    constructor(private _masterService: masterService) { }

    ngOnInit() { }

    // 过滤grid数据
    // type为搜索启用中活动
    selectListItem(type?) {
        if(type == 1) {
            this.filter.enabled = '1';
        } else {
            this.filter.enabled = '';
        }
        this.LeadDownloadActivityGoodsGrid.onChangeTable(this.filter, '1');
    }

    openModal() {
        this._masterService
            .openLeadDownload
            .emit();
    }
}
